<?php

use \Yaf\Application;
use \Yaf\Bootstrap_Abstract;
use \Yaf\Dispatcher;
use \Yaf\Loader;
use \Yaf\Registry;

class Bootstrap extends Bootstrap_Abstract
{
    public function _initLoader($dispatcher)
    {
        $loader = Loader::getInstance();
        $loader->registerLocalNamespace([
            'app' => ROOT_PATH . '/app',
        ]);
    }
    public function _initCommonFunctions()
    {
        Loader::import(APP_PATH . '/helper.php');
        Loader::import(ROOT_PATH . '/route/app.php');
    }
    public function _initComposerAutoload(Dispatcher $dispatcher)
    {
        // $autoload = ROOT_PATH . '/vendor/autoload.php';
        // if (file_exists($autoload)) {
        //     Loader::import($autoload);
        // }
    }
    public function _initConfig()
    {
        $config = Application::app()->getConfig();
        Registry::set("config", $config);
    }
    public function _initRequest()
    {
        $this->request = Dispatcher::getInstance()->getRequest();
    }
    public function _initRoute(Dispatcher $dispatcher)
    {
        $dispatcher->getRouter()->addRoute('system', new App());
    }
}
